package main.model;


public class Attribute extends Component implements Identifiable{

	
	private Cardinality cardinality = null;
	private Component parent;
	private String type = Attribute.caraterizacion;
	public static final String caraterizacion = "Caracterización";
	public static final String derivadoxcopia = "Derivado por Copia";
	public static final String derivadoxcalc = "Derivado por Calculo";
	
	public Attribute(String name){
		setName(name);
	}
	
	public Attribute() {
		super();
	}

	public void setCardinality(String min, String max){
		this.cardinality = new Cardinality(min, max);
	}
	public void setCardinality(Cardinality c){
		this.cardinality = c;
	}

	public Cardinality getCardinality(){
		return this.cardinality;
	}
	
	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("\t\t");
		if(cardinality != null){
			sb.append("\t\tCardinalidad: min: "+cardinality.getMin()+" max: " + cardinality.getMax()+ "\n\t\t");
		}
		for (Attribute atts : getIdAttributes()) {
			sb.append("\t\tAtributosId de " + getName() + " : " + atts.getName() + "\n");
			sb.append("\t\tTipo :" + getType() + "\n");
			sb.append(atts.toString());
		}
		for (Attribute atts : getAttributes()) {
			sb.append("\t\tAtributos de " + getName() + " : " + atts.getName() + "\n");
			sb.append("\t\tTipo :" + getType() + "\n");
			sb.append(atts.toString());
		}
		return sb.toString();
	}

	@Override
	public Boolean isAttribute() {
		return Boolean.TRUE;
	}

	public void setParent(Component parent) {
		this.parent = parent;
	}

	public Component getParent() {
		return parent;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

}
